package com.onenine.chat.message;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.onenine.app.R;
import com.onenine.app.utils.DataType;
import com.onenine.chat.commons.IMessage;
import com.onenine.chat.model.FriendAddExtra;


public class FriendApplyHolder<MESSAGE extends IMessage>
        extends BaseMessageViewHolder<MESSAGE>
        implements MsgListAdapter.DefaultMessageViewHolder {

    private TextView tvMsg;
    private Button btnRefuse;
    private Button btnAllow;

    public FriendApplyHolder(View itemView, boolean isSender) {
        super(itemView);
        tvMsg = itemView.findViewById(R.id.tv_msg);
        btnRefuse = itemView.findViewById(R.id.btn_refuse);
        btnAllow = itemView.findViewById(R.id.btn_allow);
    }

    @Override
    public void onBind(final MESSAGE message, final int position) {
        tvMsg.setText(message.getText());
        btnRefuse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mMsgClickListener != null) {
                    FriendAddExtra extra = new FriendAddExtra(DataType.FRIEND_DEAL_REFUSE);
                    message.setExtra(extra);
                    mMsgClickListener.onMessageClick(v, message);
                }
            }
        });
        btnAllow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mMsgClickListener != null) {
                    FriendAddExtra extra = new FriendAddExtra(DataType.FRIEND_DEAL_AGREE);
                    message.setExtra(extra);
                    mMsgClickListener.onMessageClick(v, message);
                }
            }
        });
    }

    @Override
    public void applyStyle(MessageListStyle style) {
    }
}
